﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;

using System.Linq;
using System.Linq.Expressions;
using System.Text;

using ProjectBase.Core;

using $prjsn$.Common;
using $prjsn$.Common.Validation;

namespace $safeprojectname$
{
    public class DelegateRule<TItem> : RuleBase, IValidationRule<TItem>
        where TItem : class
    {
        public delegate ValidationResult Assure(TItem item, out ValidationMessage message);
        private Assure _compiledExpression;

        public DelegateRule(Assure expression)
        {
            _compiledExpression = expression;
        }

        public virtual ValidationResult Validate(TItem item, out ValidationMessage message)
        {
            return _compiledExpression.Invoke(item, out message);
        }
    }
}